﻿#include<iostream>
using namespace std;

const int N = 10010;
int n, m, q;
int a[N][N], s[N][N];

int main()
{
	cin >> n >> m >> q;		//n行m列

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
	// 1 7 2 4	
	// 3 6 2 8
	// 2 1 2 3
	/*
	  i  j
	s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j]

	s[1][1] = s[0][1]+s[1][0]-s[0][0]+a[1][1] = 0+0-0+1 = 1;
	s[1][2] = s[0][2]+s[1][1]-s[0][1]+a[1][2] = 0+1-0+7 = 8;
	s[1][3] = s[0][3]+s[1][2]-s[0][2]+a[1][3] = 0+8-0+2 = 10;
	s[1][4] = s[0][4]+s[1][3]-s[0][3]+a[1][4] = 0+10-0+4 = 14;

	s[2][1] = s[1][1]+s[2][0]-s[1][0]+a[2][1] = 1+0-0+3 = 4;
	s[2][2] = s[1][2]+s[2][1]-s[1][1]+a[2][2] = 8+4-1+6 = 17;
	s[2][3] = s[1][3]+s[2][2]-s[1][2]+a[2][3] = 10+17-8+2 = 21;
	s[2][4] = s[1][4]+s[2][3]-s[1][3]+a[2][4] = 14+21-10+8 =33;

	s[3][1] = s[2][1]+s[3][0]-s[2][0]+a[3][1] = 4+0-0+2 = 6;
	s[3][2] = s[2][2]+s[3][1]-s[2][1]+a[3][2] = 17+6-4+1 = 20;
	s[3][3] = s[2][3]+s[3][2]-s[2][2]+a[3][3] = 21+20-17+2 = 26;
	s[3][4] = s[2][4]+s[3][3]-s[2][3]+a[3][4] = 33+26-21+3 = 41;
	*/
	while (q--)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		cout << s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
	}
	/*
	s[x2][y2]-s[x2][y1-1]-s[x1-1][y2]+s[x1-1][y1-1]

	x1 y1  x2 y2

	1  1   2  2
	s[2][2]-s[2][0]-s[0][2]+s[0][0] = 17-0-0+0=17;

	2  1   3  4
	s[3][4]-s[3][0]-s[1][4]+s[0][0] = 41-14+0=27;

	1  3   3  4
	s[3][4]-s[3][2]-s[0][4]+s[0][2] = 41-20+0 =21;
	*/
	system("pause");
	return 0;
};